#!/usr/bin/python3
#! -*- coding:utf-8 -*-

import random


# 递归实现
def binary_seek(ls, n):
    if len(ls) == 0:
        print(f"要查找的{n}不存在")
        return

    mid = (len(ls)) // 2
    if n > ls[mid]:
        ls = ls[mid + 1:]
        binary_seek(ls, n)

    elif n < ls[mid]:
        ls = ls[:mid]
        binary_seek(ls, n)

    else:
        print(f"查找的{n}找到了")
        return


lst = sorted(random.randint(-50, 50) for _ in range(10))
print(lst)
data = random.choice(lst)
binary_seek(lst, data)

